﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

using RexToy.UI.WinForm.Configuration;

namespace RexToy.UI.WinForm.Pmlx
{
    public static class PmlxFileLocatorFactory
    {
        public static IPmlxFileLocator Create()
        {
            var storage = WinFormConfig.WinFormConfiguration.Storage;
            storage.ThrowIfEnumOutOfRange();

            switch (storage)
            {
                case PmlxStorage.Embed:
                    return new EmbedLocator();

                case PmlxStorage.Isolate:
                    return new IsolateLocator();

                case PmlxStorage.Auto:
                    return new AutomaticLocator();

                default://Note:Customize
                    Type locatorType = WinFormConfig.WinFormConfiguration.CustomizePmlxLocatorType;
                    return (IPmlxFileLocator)Activator.CreateInstance(locatorType);
            }
        }
    }
}
